<!DOCTYPE html>
<html>
<head>
    <title>Basic usage</title>

    <link href="../../content/shared/styles/examples-offline.css" rel="stylesheet">
    <link href="../../../styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../../styles/kendo.default.min.css" rel="stylesheet">

    <script src="../../../js/jquery.min.js"></script>
    <script src="../../../js/kendo.web.min.js"></script>
    <script src="../../content/shared/js/console.js"></script>
    <script>
        
    </script>
    
    
</head>
<body>
    
        <a class="offline-button" href="../index.html">Back</a>
    
    <div id="example" class="k-content">
    <div class="current-state">
        <h4>Current view model state:</h4>
        <pre>
    {
        firstName: <span data-bind="text: firstName"></span>,
        lastName: <span data-bind="text: lastName"></span>,
        gender: <span data-bind="text: gender"></span>,
        agreed: <span data-bind="text: agreed"></span>
    }
        </pre>
    </div>
    <div class="registration">
        <form>
            <ul>
                <li><label for="fname">First Name:</label><input id="fname" data-bind="value: firstName" /></li>
                <li><label for="lname">Last Name:</label><input id="lname" data-bind="value: lastName" /></li>
                <li><label for="gender">Gender:</label><select id="gender" data-bind="source: genders, value: gender"></select></li>
            </ul>
            <input type="checkbox" id="agree" data-bind="checked: agreed" /> <label for="agree">I have read the licence agreement</label>
            <br /><br />
            <button data-bind="enabled: agreed, click: register" style="display: block">Register</button>
        </form>
    </div>
    <div class="confirmation" data-bind="visible: confirmed">
        Thank you for your registration, <span data-bind="text: firstName"></span> <span data-bind="text: lastName"></span>
        <br /><br />
        <button data-bind="click: startOver">Start Over</button>
    </div>
    <script>
        $(document).ready(function() {
            var viewModel = kendo.observable({
                firstName: "John",
                lastName: "Doe",
                genders: ["Male", "Female"],
                gender: "Male",
                agreed: false,
                confirmed: false,
                register: function(e) {
                    e.preventDefault();

                    this.set("confirmed", true);
                },
                startOver: function() {
                    this.set("confirmed", false);
                    this.set("agreed", false);
                    this.set("gender", "Male");
                    this.set("firstName", "John");
                    this.set("lastName", "Doe");
                }
            });

            kendo.bind($("#example"), viewModel);
        });
    </script>

    <div class="source code-sample">
        <h4 class="code-title">View source code:</h4>
        <pre class="prettyprint">
&lt;form&gt;
    &lt;label&gt;First Name: &lt;input data-bind=&quot;value: firstName&quot; /&gt;&lt;/label&gt;
    &lt;label&gt;Last Name: &lt;input data-bind=&quot;value: lastName&quot; /&gt;&lt;/label&gt;
    &lt;label&gt;Gender:
        &lt;select data-bind=&quot;source: genders, value: gender&quot;&gt;&lt;/select&gt;
    &lt;/label&gt;
    &lt;label&gt;&lt;input type=&quot;checkbox&quot; data-bind=&quot;checked: agreed&quot; /&gt; I have read the licence agreement&lt;/label&gt;
    &lt;button data-bind=&quot;enabled: agreed, click: register&quot;&gt;Register&lt;/button&gt;
    &lt;div data-bind=&quot;visible: confirmed&quot;&gt;
        &lt;h4&gt;Confirmation&lt;/h4&gt;
        &lt;div&gt;
            Thank you for your registration, &lt;span data-bind=&quot;text: firstName&quot;&gt;&lt;/span&gt; &lt;span data-bind=&quot;text: lastName&quot;&gt;&lt;/span&gt;
            &lt;br /&gt;&lt;br /&gt;
            &lt;button data-bind=&quot;click: startOver&quot;&gt;Start Over&lt;/button&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/form&gt;
        </pre>
    </div>
    <div class="source code-sample">
        <h4 class="code-title">View model source code:</h4>
        <pre class="prettyprint">
    var viewModel = kendo.observable({
        firstName: &quot;John&quot;,
        lastName: &quot;Doe&quot;,
        genders: [&quot;Male&quot;, &quot;Female&quot;],
        gender: &quot;Male&quot;,
        agreed: false,
        confirmed: false,
        register: function(e) {
            e.preventDefault();

            this.set(&quot;confirmed&quot;, true);
        },
        startOver: function() {
            this.set(&quot;confirmed&quot;, false);
            this.set(&quot;agreed&quot;, false);
            this.set(&quot;gender&quot;, &quot;Male&quot;);
            this.set(&quot;firstName&quot;, &quot;John&quot;);
            this.set(&quot;lastName&quot;, &quot;Doe&quot;);
        }
    });

    kendo.bind($(&quot;form&quot;), viewModel);
        </pre>
    </div>

    <style scoped>
        .current-state {
            float: right;
            width: 200px;
            margin: 60px 85px 0 0
        }

        .current-state pre {
            font-size: 12px;
        }

        .registration h3 {
            font-size: 2.5em;
            color: #787878;
            border-bottom: 1px solid #ccc;
        }

        .registration {
            float: left;
            clear: left;
            width: 370px;
            height: 131px;
            margin: 30px 0 30px 30px;
            padding: 60px 0 30px 30px;
            background: url('../../content/web/mvvm/regForm.png') transparent no-repeat 0 0;
        }

        .registration ul {
        	list-style: none;
            margin: 0;
            padding: 0;
        }

        .registration li {
        	height: 28px;
        	vertical-align: middle;
        	color: #000;
        }

        .registration ul label {
        	display: inline-block;
        	width: 100px;
        	text-align: right;
        	padding-right: 5px;
        	color: #000;
        }

        .registration label {
        	color: #000;
        }

        .registration ul input {
        	border: 1px solid #ddd;
        }

        .registration button {
        	float: right;
        	margin-right: 85px;
        }

        .confirmation {
            float: left;
            clear: left;
            width: 274px;
            height: 65px;
            margin: 30px 0 30px 30px;
            padding: 20px 30px;
            background: url('../../content/web/mvvm/confirm.png') transparent no-repeat 0 0;
            text-align: center;
        }

        .code-details > ul {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .code-details li
        {
            height: 26px;
            line-height: 22px;
            vertical-align: middle;
        }

        .code-details {
            padding: 1em;
        }

        .source {
            clear: both;
        }
    </style>
</div>

</body>
</html>
